package com.woniu.new_orange.util;


import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ValidExceptionHandler {
    @ExceptionHandler(BindException.class)
    public Result validExceptionHandler(BindException exception) {
        return Result.error(exception.getBindingResult().getFieldError().getDefaultMessage());
    }
}
